package cn.hxzy.controller;

import cn.hxzy.domain.Exercises;
import cn.hxzy.response.R;
import cn.hxzy.service.ProblemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.parsing.Problem;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @作者:Baiyuxiang
 * @创建时间:2024-06-22 15:54:26
 */
@RestController
@RequestMapping("/problems")
public class ProblemController {

    @Autowired
    private ProblemService problemService;

    /**
     * 导出习题资料
     *
     * @param file
     * @return
     */
    @PostMapping("/uploadProblem")
    public R uploadProblem(@RequestParam("file") MultipartFile file) {
        return null;
    }

    /**
     * 根据教师id获取习题列表
     * @param teacherId
     * @return
     */
    @GetMapping("/getList/{id}")
    public R getProblemListByTeacherId(@PathVariable("id") Long teacherId) {
        List<Exercises> exercises = problemService.getProblemListByTeacherId(teacherId);
        return R.success(exercises);
    }

    /**
     * 根据条件获取习题列表
     * @param classId
     * @param courseId
     * @param chapterId
     * @return
     */
    @GetMapping("getProblemList")
    public R getProblemList(@RequestParam(required = false) Long classId,
                            @RequestParam(required = false)  Long courseId,
                            @RequestParam(required = false)  Long chapterId,
                            @RequestParam Long teacherId
    ){
        List<Exercises> exercises = problemService.getProblemList(classId,courseId,chapterId,teacherId);
        return null;
    }

    /**
     * 根据姓名查询习题
     * @param studentName
     * @return
     */
    @GetMapping("getProblemListByName")
    public R getProblemListByName(String studentName){
        List<Exercises> exercises = problemService.getProblemListByName(studentName);
        return null;
    }
}
